|
The SQL SELECT statement returns a result set of records from one or more tables.〔(【引用サイトリンク】title=Transact-SQL Syntax Conventions )〕〔(【引用サイトリンク】title=SQL SELECT Syntax )〕 A SELECT statement retrieves zero or more rows from one or more database tables or database views. In most applications, SELECT is the most commonly used data manipulation language (DML) command. As SQL is a declarative programming language, SELECT queries specify a result set, but do not specify how to calculate it. The database translates the query into a "query plan" which may vary between executions, database versions and database software. This functionality is called the "query optimizer" as it is responsible for finding the best possible execution plan for the query, within applicable constraints.The SELECT statement has many optional clauses: * WHERE specifies which rows to retrieve.* GROUP BY groups rows sharing a property so that an aggregate function can be applied to each group.* HAVING selects among the groups defined by the GROUP BY clause.* ORDER BY specifies an order in which to return the rows.* AS provides an alias which can be used to temporarily rename tables or columns.==Examples== |- |align="center"| || |align="center"| |- |align="center"| || |align="center"| |- |align="center"| || |align="center"| |} Given a table T, the ''query'' will result in all the elements of all the rows of the table being shown. With the same table, the query will result in the elements from the column C1 of all the rows of the table being shown. This is similar to a ''projection'' in Relational algebra, except that in the general case, the result may contain duplicate rows. This is also known as a Vertical Partition in some database terms, restricting query output to view only specified fields or columns. With the same table, the query will result in all the elements of all the rows where the value of column C1 is '1' being shown — in Relational algebra terms, a ''selection'' will be performed, because of the WHERE clause. This is also known as a Horizontal Partition, restricting rows output by a query according to specified conditions. With more than one table, the result set will be every combination of rows. So if two tables are T1 and T2, will result in every combination of T1 rows with every T2 rows. E.g., if T1 has 3 rows and T2 has 5 rows, then 15 rows will result. The SELECT clause specifies a list of properties (columns) by name, or the wildcard character (“ *”) to mean “all properties”. Notice the special case of joinpropname, this provides for joins, but only on the jcr:path column, as described in 8.5.2 Database View. See also 6.6.3.1 Column Specifier. 抄文引用元・出典: フリー百科事典『 ウィキペディア(Wikipedia)』 ■ウィキペディアで「Select (SQL)」の詳細全文を読む スポンサード リンク
|